home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 050a / initcaps.zip / INITCAPS.INC
Text File  |  1993-05-07  |  4KB  |  127 lines

  1. /****************************************************************************
  2.                            Initial Caps Macro
  3.  ****************************************************************************
  4.                                   Version 2
  5.                                **************
  6.  
  7.   Copyright: 1993 David Marcus
  8.  
  9.           Permission is granted to all persons for non-commercial
  10.           distribution of this file and the macros and ideas contained
  11.           herein provided (a) credit is given to the author and (b) all
  12.           changes not made by the author are attributed.
  13.  
  14.           Permission is granted to SemWare for commercial distribution
  15.           provided (a) and (b) above.
  16.  
  17.   Author:  David Marcus
  18.  
  19.   Assistance/Enhancement: Ray Asbury
  20.  
  21.   Date:    5-7-93
  22.  
  23.   Description:
  24.  
  25.           InitCaps() is a small macro that uppercases the first
  26.           letter of each word within a marked block. Like similar
  27.           TSE commands (Upper() and Lower()), the cursor must be
  28.           inside the block.
  29.  
  30.           This file contains directions for making it part of the
  31.           standard (non-WordPerfect, etc.) TSE interface.
  32.  
  33.   Installation:
  34.  
  35.   1. Place this file in the directory where your configuration
  36.      (interface) files reside.  Add this line to your TSE.S (or other
  37.      configuration) file:
  38.  
  39.           #include ['initcaps.inc']
  40.  
  41.      Place this line anywhere in the file as long as it comes before the
  42.      procedure ChangeCase().
  43.  
  44.   2. Find the procedure ChangeCase() in your configuration file (TSE.S).
  45.      It begins with this line:
  46.  
  47.           proc ChangeCase(integer type)
  48.  
  49.   3. In that procedure, find the section that looks like this:
  50.  
  51.           case casetype
  52.               when UPPER_CASE
  53.                   Upper()
  54.               when LOWER_CASE
  55.                   Lower()
  56.               otherwise
  57.                   Flip()
  58.           endcase
  59.  
  60.   4. Add these two lines between "case casetype" and "when UPPER_CASE":
  61.  
  62.           when INIT_CAPS
  63.                InitialCaps()
  64.  
  65.   5. Find this macro in TSE.S:
  66.  
  67.           proc mUpper()
  68.                casetype = UPPER_CASE
  69.                CaseMenu("Upper Case")
  70.           end
  71.  
  72.    6. Add this macro before it:
  73.  
  74.           proc mInitCaps()
  75.                casetype = INIT_CAPS
  76.                CaseMenu("Initial Caps")
  77.           end
  78.  
  79.    7. Find your Block menu in TSE.S. It begins with this line:
  80.  
  81.           menu BlockMenu()
  82.  
  83.    8. In that menu, find this line:
  84.  
  85.       "Fl&ip   "                 ,   mFlip()             , DontClose
  86.  
  87.       Add this line beneath it:
  88.  
  89.       "Ini&tCaps"                ,   mInitCaps()         , DontClose
  90.  
  91.    9. (optional) In your TSE.KEY file, add this line after the line
  92.       containing "<Shift F4>              mUpper()".
  93.  
  94.       <Ctrl F4>               mInitCaps()
  95.  
  96.  
  97.   10. (optional) Update your help file with any of the keys listed above.
  98.  
  99.   11. Re-bind the editor using the -b switch of sc.
  100.  
  101. **************************************************************************/
  102. constant INIT_CAPS = 3
  103.  
  104. proc InitialCaps()
  105.      integer lastLine = 0
  106.      if IsBlockMarked()
  107.         PushPosition()
  108.         GotoBlockEnd()
  109.         lastLine = CurrLine()
  110.         GoToBlockBegin()
  111.         Lower()
  112.         BegLine()
  113.         repeat
  114.             if IsCursorInBlock()
  115.                 case CurrChar()
  116.                     when _AT_EOL_, _BEYOND_EOL_
  117.                     otherwise
  118.                         InsertText(UpCase(GetText(CurrPos(), 1)),
  119.                             _OVERWRITE_)
  120.                 endcase
  121.             endif
  122.         until ( NOT WordRight() )
  123.            OR ( CurrLine() > lastLine )
  124.         PopPosition()
  125.      endif
  126. end
  127.